package General;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
import java.util.Vector;
class PremierThread extends Thread
{
	
	public PremierThread(String str)
	{
		
		super(str);
	}
	
	
	public void run()
	{
		while(true)
		System.out.println("dans thread .extends.run");
	}
}

	

public class Test 
{
	    
		private static persone pers;
		public String toString()
		{
			return "le nom de la class est:";
		}
		
		
	
		
		
		
	 @SuppressWarnings("unchecked")
	public static void main(String [] args ) 
	    {
		 
			String abc="vvv";
			
		
			
			
			
			
		 final  String hh="hh";
		 int []qa =new int[5];
		 System.out.println(qa.length);
		 
		 System.out.println(hh);
		 byte hggy;
		 hggy=12;
		 System.out.println(hggy);
		 List a=new ArrayList<Object>();
		 List b=new LinkedList();
		 List c = new ArrayList();
		 Map d = new HashMap();
		 Map e= new TreeMap();
		 Vector bbbbb=new Vector();
		
		 System.out.println();
		 Bird aa=new Bird();
		 Bird cc=new Bird();
		 Set lll=new HashSet<Object>();
		 System.out.println("lll"+lll);
		 
		
		a.add(aa);
		b.add(cc);
		if(a.equals(b)){
			System.out.println(true);
		}
		 
		String string="Mystring";
		String stringg="completed"; 
		StringBuffer bf=new StringBuffer(12);
		bf.append("MyStringgggffff");
		bf.append("qqqq");
		bf.append("rrrr");
	    String s="world";
	    Bird gg= new Bird();
	    
	    int[] as={1,2};
	    int result = 0;
	    for (int i : as)
	        result=i+1;
	    List<String> tt=new ArrayList<String>();
	    tt.add("bonjour");
	    tt.add("le");
	    tt.add("monde");
	    Iterator<String> it=tt.iterator();
	    
	    while(it.hasNext())
	    	System.out.println(it.next());
			
	    Dog dog=new Dog(0, "essouri", "mohamed");
	    System.out.println(dog.toString());
			
		 	
	     int i=3;
		 Test hhh=new Test();
		 
		 
		 persone per=new persone("sss", "ffff");
			persone per1=null;
			per1=(persone) per.clone();
			System.out.println("fff"+per1.getNom());
		 Runtime r=Runtime.getRuntime();
		 
		 System.out.println(r.availableProcessors());
		 
		 System.out.println(new Bird().name);
		 
		 long a1=1, a2=1, a3=2, a4=2;
		 if(a1==a2)
			 System.out.println("1");
		 if(a3==a4)
			 System.out.println("2");
		
		PremierThread pr=new PremierThread("first");
		
		
		
		
		LinkedList g=new LinkedList<String>();
		ArrayList ggg=new ArrayList<String>();
		HashMap jjj=new HashMap<String,Object>(300);
		 List g1=new LinkedList<String>();
		ArrayList ggg1=new ArrayList<String>();
		Map jjj1=new HashMap<String,Object>(1000);
		HashSet jjj12=new HashSet<String>(12);
		int a5[]={1};
		
		
		
		String S="eeeee";
		try
		{
			S="try";
			throw new Exception();
		}catch(Exception ex)
		{
			S="catch";
		}
		
	finally
	{
		//S="finally";
	}
		
		System.out.println(S);
		
		List bbb=new ArrayList<String>();
		bbb.add("c");
		bbb.add("b");
		bbb.add("a");
		Collections.sort(bbb,Collections.reverseOrder());
		System.out.println(bbb);
		
		Properties pros= new Properties();
		
		pros.setProperty("user","simo2");
		pros.setProperty("password", "simo2");
		pros.setProperty("autoReconnect", "true");
		String url="jdbc:oracle:thin:@localhost:1521:projetin";
		String driver="oracle.jdbc.driver.OracleDriver";
		Connection con=null;
		try
		{
		Class.forName(driver);
		
				con=DriverManager.getConnection(url, pros);
		}catch(ClassNotFoundException er)
		{
			System.out.println("driver non trouvable");
		}
		catch(SQLException sq)
		{
			System.out.println("erreur sql");
		}
		finally
		{
			if(con !=null)
				System.out.println(true);
		}
		
		
		
		try
		{
			con=DriverManager.getConnection(url, pros);
				
				Statement sat=null;
				int nombre =21;
				String nom="mede";
				String sql="INSERT INTO mag(nombre,nom) VALUES ('"+nombre+"','"+nom+"')";
			    sat.executeUpdate(sql);
			  
			
			
			
				System.out.println();
			
			
		}catch(SQLException sq)
		{
			
		}
		
		try
		{
		
			
		
		}
		catch(Exception eb)
		{
			
		}
		
	}
	 
	    
	 }
 class persone implements Cloneable{
	 
	 public persone() {
		super();
		// TODO Auto-generated constructor stub
	}
	private String nom;
		private String prenom;
		public persone(String nom, String prenom) {
			super();
			this.nom = nom;
			this.prenom = prenom;
		}
		
		public String getNom() {
			return nom;
		}

		public void setNom(String nom) {
			this.nom = nom;
		}

		public String getPrenom() {
			return prenom;
		}

		public void setPrenom(String prenom) {
			this.prenom = prenom;
		}

		public Object clone(){
			try { 
			return super.clone() ;
			}
			catch (CloneNotSupportedException e) {
			throw new InternalError() ; 
			
			}
		
}
 }
	   



